package com.jy.wms.web;

import com.jy.wms.common.base.BaseSessionInfo;
import com.jy.wms.pojo.SysHz;
import com.jy.wms.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @ClassName: UserController
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @Author lh
 * @Date 2018/8/28 0028
 */
@Controller
@RequestMapping("/wmsCustomerFileRouter")
public class WmsCustomerFileRouter {
    @Autowired
    SysMenuService menuService;
    /* 跳转到客户档案页面*/
    @RequestMapping(value = "/toCustomerFile/{menu}")
    public String toCustomerFile(@PathVariable("menu") String menu, Model model){
        model.addAttribute("functions",menuService.getFunctions(menu));
        return "business/customer/customerFile";
    }
    /* 跳转到客户档案新增页面*/
    @RequestMapping(value = "/toAddCustomerFile")
    public String toAddCustomerFile(HttpSession session,Model model){
        List<SysHz> hz = (List) session.getAttribute(BaseSessionInfo.SessionConsignor);
        String hzmc="";
        if (hz.size() > 0) {
            hzmc = hz.get(0).getShow_hzid();
            model.addAttribute("hzmc",hzmc);
        }
        return "business/customer/addCustomer";
    }

    /* 跳转到客户档案修改页面*/
    @RequestMapping(value = "/toEditCustomerFile")
    public String toEditCustomerFile(String id,HttpSession session, Model model ){
        List<SysHz> hz = (List) session.getAttribute(BaseSessionInfo.SessionConsignor);
        String hzmc="";
        if (hz.size() > 0) {
            hzmc = hz.get(0).getShow_hzid();
            model.addAttribute("hzmc",hzmc);
        }
        model.addAttribute("id",id);
        return "business/customer/editCustomer";
    }

    /* 跳转到客户档案详情页面*/
    @RequestMapping(value = "/toDetail")
    public String toDetail( String id,Model model ){
        model.addAttribute("id",id);
        return "business/customer/detail";
    }

    /* 跳转到新增客户地址页面*/
    @RequestMapping(value = "/toAddAddress")
    public String toAddAddress( String id,Model model ){
        System.out.println("id:"+id);
        model.addAttribute("sskhid",id);
        return "business/customer/addAddress";
    }

    /* 跳转到查看收货人页面*/
    @RequestMapping(value = "/toConsigneeDetail")
    public String toConsigneeDetails( String id,Model model ){
        model.addAttribute("sskhid",id);
        return "business/customer/consigneeDetail";
    }
    /* 跳转到查看车辆信息页面*/
    @RequestMapping(value = "/toCarrierDetail")
    public String toCarrierDetail( String id,Model model ){
        model.addAttribute("sskhid",id);
        return "business/customer/carrierDetail";
    }
    /* 跳转到查看仓库信息页面*/
    @RequestMapping(value = "/toWarehouseDetail")
    public String toWarehouseDetail( String id,Model model ){
        model.addAttribute("sskhid",id);
        return "business/customer/warehouseDetail";
    }
}
